<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

require_once 'core/app/AppMailSender.php';


class KBClientMailSender extends AppMailSender
{
	
	// to support about new user question
	function sendContactNotification($vars) {

		$this->letter_key = 'contact';

		// parser
		$parser = &$this->parser;
		$parser->assign($vars);
		
		// mail object
		$mail = &$this->getMailerObj($this->getTemplateVars(), $vars);
		$mail->From = $vars['email'];
		$mail->FromName = '';
		
		if(!empty($vars['attachment'])) {
			foreach($vars['attachment'] as $file) {
				$filename = basename($file);	
				$mail->AddAttachment($file, $filename);  // optional name
			}
		}
		
		$mail->Body = &$parser->parse($this->getTemplate());
		
		//echo "<pre>"; print_r($mail); echo "</pre>";
		//exit();
		
		return $mail->Send();
	}
	
	
	function sendToFriend($vars) {
		
		$this->letter_key = 'send_to_friend';

		// parser
		$parser = &$this->parser;
		$parser->assign($vars);
		$parser->assign('link', $vars['entry_link']);
		$parser->assign('message', $vars['comment']);
		
		// mail object
		$mail = &$this->getMailerObj($this->getTemplateVars());
		$mail->From = $vars['your_email'];
		$mail->FromName = $vars['name'];
		
		$mail->ClearAddresses();
		$mail->AddAddress($vars['friend_email']);
		
		$mail->Body = &$parser->parse($this->getTemplate());
		
		//echo "<pre>"; print_r($mail); echo "</pre>";
		//exit();
		
		return $mail->Send();
	}
	
	
	function sendConfirmRegistration($vars) {
		
		$this->letter_key = 'confirm_registration';

		// parser
		$parser = &$this->parser;
		$parser->assign($vars);
		$parser->assign('login', $vars['username']);
		$parser->assign('password', $vars['password']);
		
		// mail object
		$mail = &$this->getMailerObj($this->getTemplateVars());
		$mail->From = $this->noreply_email;
		$mail->FromName = $this->from_mailer;
		
		$mail->ClearAddresses();
		$mail->AddAddress($vars['email']);
		
		$mail->Body = &$parser->parse($this->getTemplate());
		
		//echo "<pre>"; print_r($mail); echo "</pre>"; 
		//exit();	
		
		return $mail->Send();		
	}
	
	
	function sendGeneratedPassword($vars) {
		
		$this->letter_key = 'generated_password';

		// parser
		$parser = &$this->parser;
		$parser->assign($vars);
		$parser->assign('name', $vars['first_name'] . ' ' . $vars['last_name']);
		$parser->assign('login', $vars['username']);
		
		
		// mail object
		$mail = &$this->getMailerObj($this->getTemplateVars());
		$mail->From = $this->noreply_email;
		$mail->FromName = $this->from_mailer;
		
		$mail->ClearAddresses();
		$mail->AddAddress($vars['email']);
		
		$mail->Body = &$parser->parse($this->getTemplate());
		
		//echo "<pre>"; print_r($mail); echo "</pre>"; 
		//exit();	
		
		return $mail->Send();
	}
}
?>